<template>
  <div class="ai-quick-access">
    <!-- 浮动AI按钮 -->
    <el-button 
      class="ai-floating-btn"
      type="primary" 
      circle
      size="large"
      @click="openAiDemo"
      title="打开AI助手"
    >
      🌙
    </el-button>

    <!-- 或者作为普通按钮 -->
    <el-button 
      v-if="showInlineButton"
      type="primary" 
      @click="openAiDemo"
      :icon="ChatDotRound"
    >
      🌙 AI助手
    </el-button>

    <!-- AI功能弹窗 -->
    <el-dialog
      v-model="dialogVisible"
      title="🌙 Moonshot AI 助手"
      width="90%"
      :before-close="handleClose"
      class="ai-dialog"
      draggable
    >
      <MoonshotChat />
    </el-dialog>
  </div>
</template>

<script>
import { ref } from 'vue'
import { ChatDotRound } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import MoonshotChat from './MoonshotChat.vue'

export default {
  name: 'AiQuickAccess',
  components: {
    ChatDotRound,
    MoonshotChat
  },
  props: {
    // 是否显示内联按钮（非浮动）
    showInlineButton: {
      type: Boolean,
      default: false
    },
    // 是否在弹窗中打开（而不是跳转页面）
    openInDialog: {
      type: Boolean,
      default: false
    }
  },
  setup(props) {
    const router = useRouter()
    const dialogVisible = ref(false)

    const openAiDemo = () => {
      if (props.openInDialog) {
        // 在弹窗中打开
        dialogVisible.value = true
      } else {
        // 跳转到演示页面
        router.push('/moonshot-demo')
      }
    }

    const handleClose = (done) => {
      done()
    }

    return {
      dialogVisible,
      openAiDemo,
      handleClose
    }
  }
}
</script>

<style scoped>
.ai-quick-access {
  position: relative;
}

.ai-floating-btn {
  position: fixed;
  bottom: 80px;
  right: 30px;
  z-index: 1000;
  width: 60px;
  height: 60px;
  font-size: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
}

.ai-floating-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.ai-dialog {
  --el-dialog-border-radius: 12px;
}

.ai-dialog :deep(.el-dialog__body) {
  padding: 0;
  height: 600px;
}
</style>
